package com.jackie.coupon.template.dao.convert;

import com.jackie.coupon.template.api.enums.CouponType;

import javax.persistence.AttributeConverter;

/**
 * CouponTypeConverter
 *
 * @author Jackie Hou
 * @date 2023/11/17 09:33
 * @version 1.0
 */
public class CouponTypeConverter implements AttributeConverter<CouponType, String> {
    @Override
    public String convertToDatabaseColumn(CouponType couponType) {
        return couponType.getCode();
    }

    @Override
    public CouponType convertToEntityAttribute(String code) {
        return CouponType.convert(code);
    }
}
